<%--
  Created by IntelliJ IDEA.
  User: 哥只是个传说
  Date: 2020/12/1 0001
  Time: 15:35
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta charset="UTF-8">
    <title>当当网</title>
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/index.css" />
</head>
<body>
<div class="bg">
    <div class="logo lfet"></div>
    <div class="font lfet">用户登录>>></div>
    <div class="wizard right">
        <div class="wizard-header">
            <h3>Phone Manger System</h3>
        </div>
        <form>
            <div class="content">
                <div class="col">
                    <div class="form-group">
                        <label class="lfet">NickName</label>
                        <input type="text" class="form-control error inp-bg1" name="nickname" style="outline: none;">
                    </div>
                    <div class="form-group">
                        <label class="lfet">Password</label>
                        <input type="password"  class="form-control error mminp" name="password" style="outline: none;">
                    </div>
                    <label class="lfet">验证码</label>
                    <img class="yzm_img" id='imgVcode' style="border: 1px black solid; margin-left: 60px" src="${pageContext.request.contextPath}/getCodeImg" />
                    <input type="text" name="code" style="width: 180px"/>
                    <div class="bottom" style="text-align: center;">
                        <!-- 这个button也可以提交表单，不需要改成submit -->
                        <button style="text-align: center;" type="button" onclick="login()">Login</button>
                    </div>
                </div>
            </div>
        </form>
    </div>
</div>
<script type="text/javascript" src="js/jquery-1.12.4.js"></script>
<script type="text/javascript" src="js/jquery.serializejson.js"></script>
<script type="text/javascript">
    function login() {
        $.ajax({
            url:"${pageContext.request.contextPath}/login",
            type:"post",
            sync : "false",
            data:"nickname="+$("[name=nickname]").val()+"&password="+$("[name=password]").val()+"&code="+$("[name=code]").val(),
            success:function (data) {
                if(data){
                    window.location.href="product.jsp";
                }else {
                    alert("账号或密码有误")
                }
            }
        })
    }
</script>
</body>
</html>

